﻿package rosa.events {
	import flash.events.IEventDispatcher;			import rosa.EventHandlingFeature;		/**	 * Factory for creation of event handling strategy. Internal use.
	 * @author Joseba Alonso
	 */
	public class EventHandlerFactory 	{		/**		 * Creates a IEventHandler object that will handle the events emitted by the service		 * @param eventHandling EventHandlingFeature enum value wich identifies the strategy for event handling		 * @param emitter The service that will dispatch the events.		 * @param view Used by the AUTOWIRE_VIEW_EVENTS feature only. Identifies the view that will recive the events.		 * @return Event handler delegate.		 */		public static function create(eventHandling:String,emitter:IEventDispatcher,view:Object = null):IEventHandler		{			switch(eventHandling)			{				case EventHandlingFeature.DISPATCH_SUBSCRIBERS:					return new SubscriberDispatcher(emitter);					break;				case EventHandlingFeature.AUTOWIRE_VIEW_EVENTS:					return new ViewEventsWirer(emitter,view);					break;				default:					throw new Error("Invalid event handling feature");			}
		}	}
}
